<?php
/*
+ ---------------------------------------------------------------------- +
| e107Shop - An e-commerce plugin for the e107 content management system |
|                                                                        |
| ByOrder Europe 2007-2008                                               |
| http://e107shop.com                                                    |
| patrick@byorder.nl                                                     |
|                                                                        |
| Released under the terms and conditions of the LGPL                    |
|                                                                        |
| $Revision: 1.0                                                         |
| $Date: 2008/08/20                                                      |
| $Author: Bieleke                                                       |
+ ---------------------------------------------------------------------- +
*/

function e107shop_get_cartid() {
    global $pref;
    // if e107 cms is using cookies start a session
    if (!$pref['user_tracking'] == "session") {
        session_start();
    }
    // Check if the cartid IS set
    if ($_SESSION['cartid']) {
        return $_SESSION['cartid'];
    } else {        
        $_SESSION['cartid'] = uniqid(md5(rand()),true);
        // Return the unique ID for use within the script
        return $_SESSION['cartid'];
    }
}

function destroy_e107shop_cookie() {
    //global $shop_settings;
    $cookiename = str_replace(" ", "_", $shop_settings["store_name"]);
    session_regenerate_id(TRUE);
    setcookie ($cookiename, "", time() - 7200, "/", false);
}
